#include<pthread.h>
#include<iostream>
#include<vector>
#include<unistd.h>
using namespace std;
const int n = 10;
class ThreadData
{
public:
    int _x;
    int _y;
    char _op;
};

void* Route(void* args)
{
    while(true)
        sleep(1);
    const char* name = static_cast<const char*>(args);
    cout<<"name:"<<name<<endl;
    // return (void*)name;
    pthread_exit((void*)name);
}

int main(){
    std::vector<pthread_t> tids;
    for(int i = 0;i < n;++i){
        pthread_t tid;
        char* name = new char[128]{0};
        snprintf(name,128,"thread-%d",i+1);
        int n = pthread_create(&tid,nullptr,Route,(void*)name);
        if(n < 0){
            cout<<"create err"<<endl;
            exit(-1);
        }
        tids.emplace_back(tid);
    }
    sleep(2);
    for(int i = 0;i < n;++i){
        pthread_cancel(tids[i]);
        void* name;
        pthread_join(tids[i],(void**)&name);
        cout<<(long long int)name<<" quit"<<endl;
    }
    return 0;
}